-
Notifications
You must be signed in to change notification settings - Fork 53
Add scheduled auto-closure for stale “Needs Author Feedback” issues #566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: YunchuWang <[email protected]>
Co-authored-by: YunchuWang <[email protected]>
Co-authored-by: YunchuWang <[email protected]>
Co-authored-by: YunchuWang <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a GitHub Actions workflow to automatically close issues labeled "Needs Author Feedback" after 7 days of inactivity. However, the repository already has an existing GitOps policy (.github/policies/resourceManagement.yml) that performs the same function with the label "Needs: Author Feedback" (note the colon). The new workflow creates duplication and uses an inconsistent label format that won't match existing issues.
Key Changes
- Adds scheduled daily workflow (09:00 UTC) with manual trigger support
- Implements 7-day inactivity check and automatic closure with comment notification
- Includes error handling for comment creation and issue closure operations
| name: Close inactive author feedback issues | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: "0 9 * * *" | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
| issues: write | ||
|
|
||
| jobs: | ||
| close-inactive: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Close issues waiting on author feedback | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| script: | | ||
| const label = "Needs Author Feedback"; | ||
| const daysInactive = 7; | ||
| const cutoff = new Date(Date.now() - daysInactive * 24 * 60 * 60 * 1000); | ||
|
|
||
| const { owner, repo } = context.repo; | ||
| const issues = await github.paginate(github.rest.issues.listForRepo, { | ||
| owner, | ||
| repo, | ||
| state: "open", | ||
| labels: label, | ||
| per_page: 100, | ||
| sort: "updated", | ||
| direction: "asc", | ||
| }); | ||
|
|
||
| for (const issue of issues) { | ||
| if (issue.pull_request) { | ||
| continue; | ||
| } | ||
|
|
||
| const updatedAt = new Date(issue.updated_at); | ||
| if (updatedAt > cutoff) { | ||
| continue; | ||
| } | ||
|
|
||
| const body = [ | ||
| "We haven't heard back in 7 days, so we're automatically closing this issue.", | ||
| "If you still need help, please reply and we can reopen it." | ||
| ].join("\n\n"); | ||
|
|
||
| try { | ||
| await github.rest.issues.createComment({ owner, repo, issue_number: issue.number, body }); | ||
| } catch (error) { | ||
| console.warn(`Skipping issue #${issue.number} because of an error while adding the notice: ${error}`); | ||
| continue; | ||
| } | ||
|
|
||
| try { | ||
| await github.rest.issues.update({ owner, repo, issue_number: issue.number, state: "closed" }); | ||
| } catch (error) { | ||
| console.warn(`Skipping issue #${issue.number} because of an error while processing closure: ${error}`); | ||
| } | ||
| } |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This workflow duplicates functionality already handled by the existing GitOps policy in .github/policies/resourceManagement.yml (lines 11-43). The existing policy already closes issues with "Needs: Author Feedback" label after 7 days of inactivity (4 days for warning + 3 days to close). Having two separate systems managing the same process creates potential conflicts, confusion, and maintenance overhead. Consider whether this workflow is necessary, or if the existing policy should be modified instead.
| name: Close inactive author feedback issues | |
| on: | |
| schedule: | |
| - cron: "0 9 * * *" | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| issues: write | |
| jobs: | |
| close-inactive: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Close issues waiting on author feedback | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const label = "Needs Author Feedback"; | |
| const daysInactive = 7; | |
| const cutoff = new Date(Date.now() - daysInactive * 24 * 60 * 60 * 1000); | |
| const { owner, repo } = context.repo; | |
| const issues = await github.paginate(github.rest.issues.listForRepo, { | |
| owner, | |
| repo, | |
| state: "open", | |
| labels: label, | |
| per_page: 100, | |
| sort: "updated", | |
| direction: "asc", | |
| }); | |
| for (const issue of issues) { | |
| if (issue.pull_request) { | |
| continue; | |
| } | |
| const updatedAt = new Date(issue.updated_at); | |
| if (updatedAt > cutoff) { | |
| continue; | |
| } | |
| const body = [ | |
| "We haven't heard back in 7 days, so we're automatically closing this issue.", | |
| "If you still need help, please reply and we can reopen it." | |
| ].join("\n\n"); | |
| try { | |
| await github.rest.issues.createComment({ owner, repo, issue_number: issue.number, body }); | |
| } catch (error) { | |
| console.warn(`Skipping issue #${issue.number} because of an error while adding the notice: ${error}`); | |
| continue; | |
| } | |
| try { | |
| await github.rest.issues.update({ owner, repo, issue_number: issue.number, state: "closed" }); | |
| } catch (error) { | |
| console.warn(`Skipping issue #${issue.number} because of an error while processing closure: ${error}`); | |
| } | |
| } | |
| # (File deleted) |
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| script: | | ||
| const label = "Needs Author Feedback"; | ||
| const daysInactive = 7; |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 7-day inactivity period conflicts with the existing policy timing. The current resourceManagement.yml policy uses a 7-day total process: adds a warning comment after 4 days of inactivity, then closes after 3 more days. This provides users with advance notice. The new workflow closes issues immediately after 7 days without prior warning. Consider aligning with the existing two-stage approach to provide better user experience, or clearly document why a different approach is needed.
| "We haven't heard back in 7 days, so we're automatically closing this issue.", | ||
| "If you still need help, please reply and we can reopen it." |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The closing message should match the established tone and format used in the existing policy. The current resourceManagement.yml uses a more formal message structure that includes markdown formatting for emphasis. Consider using a message consistent with the existing policy's style.
| "We haven't heard back in 7 days, so we're automatically closing this issue.", | |
| "If you still need help, please reply and we can reopen it." | |
| "**This issue has been automatically closed due to lack of author feedback after 7 days.**", | |
| "", | |
| "If you still require assistance, please comment on this issue and we will be happy to reopen it." |
| labels: label, | ||
| per_page: 100, | ||
| sort: "updated", | ||
| direction: "asc", |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The workflow retrieves all open issues with the label and filters them in memory. For repositories with many issues, this could be inefficient. Consider adding the 'since' parameter to the API call to filter issues at the API level based on the cutoff date, reducing the amount of data transferred and processed.
| direction: "asc", | |
| direction: "asc", | |
| since: cutoff.toISOString(), |
| on: | ||
| schedule: | ||
| - cron: "0 9 * * *" | ||
| workflow_dispatch: |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The workflow_dispatch trigger should have empty braces for consistency with the codeQL.yml workflow in this repository (line 15), which uses explicit empty object notation. Update to 'workflow_dispatch: {}' for consistency.
| workflow_dispatch: | |
| workflow_dispatch: {} |
| try { | ||
| await github.rest.issues.update({ owner, repo, issue_number: issue.number, state: "closed" }); | ||
| } catch (error) { | ||
| console.warn(`Skipping issue #${issue.number} because of an error while processing closure: ${error}`); | ||
| } |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the issue closure fails but the comment was successfully posted, the issue will remain open with a closure notice that's inaccurate. The existing resourceManagement.yml policy handles this atomically through its action system. Consider adding a state check or removing the comment if closure fails to maintain consistency between the comment message and actual issue state.
| with: | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| script: | | ||
| const label = "Needs Author Feedback"; |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The label "Needs Author Feedback" does not match the existing label format used in the repository. The existing policy in .github/policies/resourceManagement.yml uses "Needs: Author Feedback" (with a colon). This inconsistency means the workflow will target different issues than intended. Update the label to match the existing convention: "Needs: Author Feedback".
| const label = "Needs Author Feedback"; | |
| const label = "Needs: Author Feedback"; |
Automatically close issues labeled “Needs Author Feedback” after 7 days of inactivity to keep the backlog current.
Example (workflow snippet):
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.